const cheerio = require("cheerio");
const Debug = require("debug");
const dbg = Debug("[test-cheerio]");dbg.enabled=true;

let pieces = [
    `<html xmlns="http://www.w3.org/1999/xhtml"><head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>QQ Message</title><style type="text/css">body{font-size:12px; line-height:22px; margin:2px;}td{font-size:12px; line-height:22px;}</style></head><body><table width=100% cellspacing=0>
    <tr><td><div style=padding-left:10px;><br><b>消息记录</b></div></td></tr>
    <tr><td><div style=padding-left:10px;>消息分组:我的QQ群</div></td></tr>
    <tr><td><div style=padding-left:10px;>消息对象:阿里巴巴2018校招内推</div></td></tr>
    <tr><td><div style=padding-left:10px;>&nbsp;</div></td></tr>
    <tr><td style=border-bottom-width:1px;border-bottom-color:#8EC3EB;border-bottom-style:solid;color:#3568BB;font-weight:bold;height:24px;line-height:24px;padding-left:10px;margin-bottom:5px;>日期: 2018-03-01</td></tr>
    <tr><td><div style=color:#006EFE;padding-left:10px;><div style=float:left;margin-right:6px;>系统消息(10000)</div>17:13:06</div><div style=padding-left:20px;><font style="font-size:9pt;font-family:'','MS Sans Serif',sans-serif;" color='505050'>你已经是群成员了，和大家打个招呼吧！</font></div></td></tr>`,
    `<tr><td style=border-bottom-width:1px;border-bottom-color:#8EC3EB;border-bottom-style:solid;color:#3568BB;font-weight:bold;height:24px;line-height:24px;padding-left:10px;margin-bottom:5px;>日期: 2018-03-02</td></tr><tr><td><div style=color:#006EFE;padding-left:10px;><div style=float:left;margin-right:6px;>系统消息(10000)</div>0:55:54</div><div style=padding-left:20px;><font style="font-size:9pt;font-family:'','MS Sans Serif',sans-serif;" color='505050'>长空加入本群</font></div></td></tr>`,
    `</table></body></html>`
];

for(let piece of pieces){
    let $ = cheerio.load(piece,{
        decodeEntities:false,//很重要，保持中文的原样
        normalizeWhitespace: false
    });
    let trs = $("tr");
    if(trs.length){
        for(let i=0;i<trs.length; i++){
            let t_tr = $(trs[i]);
            let html_tr = t_tr.html();
            dbg(html_tr);
        }
    }
}

//cherrio
//在处理第2/3个时失效...